<template>
  <div v-if="hasPermission">
    <slot></slot>
  </div>
  <div v-else class="no-permission">
    <el-empty description="暂无权限" />
  </div>
</template>

<script setup>
import { computed } from 'vue'
import { useRoute } from 'vue-router'
import { useMainStore } from '@/stores/useMain'

const props = defineProps({
  type: {
    type: String,
    required: true,
    validator: (value) => ['exam', 'show'].includes(value)
  }
})

const mainStore = useMainStore()
const route = useRoute()

const hasPermission = computed(() => {
  if (props.type === 'exam') {
    return mainStore.userInfo.examEnabled
  }
  if (props.type === 'show') {
    return mainStore.userInfo.showEnabled
  }
  return false
})
</script>

<style scoped>
.no-permission {
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px;
}
</style> 